﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
using System.Net;

namespace 智慧大棚三人成行
{
    public class Emailhelp
    {


        public static bool SendMail(string mailForm, string mailTo, string mailTitle, string body)
        {


            // 发送邮件的对象
            SmtpClient smtpClient = new SmtpClient();
            // 发送邮件的地址
            smtpClient.Host = "smtp.qq.com";
            // 指定是否使用加密连接
            smtpClient.EnableSsl = true;
            // 
            smtpClient.UseDefaultCredentials = true;
            // 通过网络发送smtp邮件
            smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
            // 设置发送的账号密码
            smtpClient.Credentials = new NetworkCredential("2550877295@qq.com", "hbopaasdigcgbbbb");


            // 邮件类  包含发送者  接收者  标题   主体
            //MailMessage mailMessage = new MailMessage(mailForm,mailTo,mailTitle,body);
            try
            {
                smtpClient.Send(mailForm, mailTo, mailTitle, body);
                return true;
            }
            catch (Exception)
            {


                return false;
            }





        }

    }
}
